package xin.marcher.module.seller.test.mapper;

import org.junit.Test;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URL;

/**
 *
 */
public class ForJmeterCreateParameterFile {

    @Test
    public void getSellerInfo() {
        StringBuilder sb = new StringBuilder();
        sb.append("sellerId").append("\n");
        for (Long param : ForJmeterCreateMockData.SELLER_INFO_ID_RANGE.asList()) {
            sb.append(param).append("\n");
        }
        sb.setLength(sb.length() - 1);

        writeToFile(sb.toString(), "getSellerInfo.txt");
    }

    private void writeToFile(String str, String fileName) {
        try {
            URL classpath = ClassLoader.getSystemResource("");
            String paramFilePath = classpath.getFile() + File.separator + fileName;
            FileWriter fileWriter = new FileWriter(paramFilePath);
            fileWriter.write(str);
            fileWriter.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
